package com.itnature.testchip.process;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import org.apache.log4j.Logger;

public class ApplicationUtil {

	public static String readFile(String testFlowFile)
			throws FileNotFoundException, IOException {
		String content = "";
		File f = new File(testFlowFile);
		long length = f.length();
		if(length >= Integer.MAX_VALUE) {
			Logger.getLogger(ApplicationUtil.class.getName()).debug("Kich thuoc file "+testFlowFile +" qua lon");
			return null;
		}
		
		FileReader fReader = new FileReader(f);
		BufferedReader bufReader = new BufferedReader(fReader);
		
		char[] arr = new char[(int) f.length()];
		bufReader.read(arr, 0, arr.length);
		content = new String(arr);
		
		bufReader.close();
		fReader.close();
		return content;
	}

}
